<template>
  <view>
    <nav-bar title="联系我们"></nav-bar>
    <scroll-view scroll-y :style="{ height: scrollHeight }">
      <view class="content-box">
        <rich-text :nodes="contractContent"></rich-text>
      </view>
    </scroll-view>
  </view>
</template>

<script>
  import api_user from '@/api/user'
  export default {
    name: 'NewsInfoDetail',
    data() {
      return {
        scrollHeight: '',
        newsId: '',
        contractContent: ''
      }
    },
    onLoad() {
      this.scrollHeight = this.$store.getters.heightData.noTabMainHeight + 'px'
      this.getContractDetail()
    },
    methods: {
      getContractDetail() {
        const params = {
          id: 15 // 联系我们的内容
        }
        api_user.fetchNewsDetail(params).then(res => {
          if (res.code !== 200) return
          const result = res.data
          const imgContent = result.content && result.content.includes('<img') ? result.content.replace(/\<img/g, '<img style="width: 100%;height: auto"') : result.content
          this.contractContent = imgContent && imgContent.replace(/\n/g, '<br/>')
        })
      }
    }
  }
</script>
<style lang="scss" scoped>
  .content-box {
    padding: 30rpx;
    line-height: 48rpx;
    font-size: 28rpx;
    color: #666;
  }
</style>
